package com.handtransaction.controller;

import com.handtransaction.entity.DataBean;
import com.handtransaction.entity.Goods;
import com.handtransaction.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.List;

@Controller
public class ConsoleDataController {
    @Qualifier("dataStatisticsServiceImpl")
    @Autowired
    DataStatisticsService dataService;
    @Autowired
    private GoodsService goodsService;
    @Autowired
    private UserService userService;
    @Autowired
    private OrderService orderService;
    @Autowired
    private OffShelfService offShelfService;
    @Autowired
    private  TipOffService tipOffService;

    //后台首页
    @RequestMapping("/showConsoleHomePage")
    public String showConsoleHomePage(Model model){
        //获取报表数据
        //model.addAttribute("LastWeek" , getLastSevenDate());
        model.addAttribute("dataBeans" , dataService.showNew7DayData());
        model.addAttribute("dataMap" , dataService.showAllIndex());
        return "admin/consoleHomePage";
    }

    //后台数据统计显示
    @RequestMapping("/showConsoleData")
    public String showConsoleData(Model model){
        model.addAttribute("indexs" , dataService.showAllIndex());
        model.addAttribute("dataBeanList", dataService.showNew7DayData());
        model.addAttribute("mostCategoryList", dataService.showMostTenCategory());
        List<Goods> list = dataService.showAllTransactionCategory();
        int var = list.size();
        model.addAttribute("lastOneTransactionCategory", list.get(var-1));
        list.remove(var-1);
        model.addAttribute("transactionCategoryList", list);
        return "admin/dataStatistics";
    }




}
